package com.hbsx.why.views;

import android.content.Context;
import android.os.Build;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;

import com.hbsx.why.utils.CommonUtils;

/**
 * Created by liub
 * time 2017/8/29
 */

public class StatueBarView extends View {
    private Context context;

    public StatueBarView(Context context) {
        super(context);
        this.context = context;
    }

    public StatueBarView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
    }

    public StatueBarView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            int statusBarHeight = CommonUtils.getStatusHeight(context);
            setMeasuredDimension(widthMeasureSpec, statusBarHeight);
        } else {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        }

    }
}
